@extends('backend.template.bootstrap')
@section('content')
<div id="page-wrapper" >
    <div id="page-inner">
        <div class="row">
            <div class="col-md-12">
                <h1 class="page-header">
                    文章管理 <small>Articles.</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="#">首页</a></li>
                    <li><a href="{{ url('backend/articles') }}">文章</a></li>
                    <li class="active">@if(!$article->exists)写文章@else {{ $article->title }} 编辑@endif</li>
                </ol>
            </div>
        </div>
        <!-- /. ROW  -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body">
						@if (Session::has('msg'))
			                <div class="alert alert-danger">
								<strong>错误!</strong>   
								{{ Session::get('msg') }}
							</div>
						@elseif ($errors->any())
			                <div class="alert alert-danger">
								<strong>错误!</strong> 
								{{ $errors->first() }}
							</div>
						@endif
                        <div class="row">
                            <div class="col-lg-10">
                                @if (!$article->exists)
                                    {!! Form::open(array('mothed' => 'POST', 'url' => 'backend/articles', 'role' => 'form', 'onkeydown' => 'if(window.event.keyCode==13){return false;}')) !!}
                                @else
                                    {!! Form::model($article, array('method' => 'PATCH', 'url' => array('backend/articles', $article->id), 'role' => 'form'))  !!}
                                @endif
                                    <div class="form-group">
                                        {!! Form::label('title', '标题') !!}
                                        {!! Form::text('title', $article->title, array('class' => 'form-control', 'placeholder' => '请输入标题')) !!}
                                    </div>
                                    <div class="form-group">
                                        {!! Form::label('author', '作者') !!}
                                        {!! Form::text('author', $article->author, array('class' => 'form-control', 'placeholder' => '请输入作者')) !!}
                                    </div>
                                    <div class="form-group">
                                        {!! Form::label('category_id', '分类') !!}
                                        <div class="controls">
                                            {!! Form::select('category_id', $categories, $article->category_id, array('class' => 'form-control')) !!}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        {!! Form::label('content', '内容') !!}
                                        <div class="controls">
                                            <script id="content" name="content" type="text/plain">{!!  $article->content  !!}</script>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary"><i class="icon-ok"></i> 保存</button>
                                {!! Form::close() !!}
                            </div>
                        </div>
                        <!-- /.row (nested) -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
        </div>
    </div>
    <!-- /. PAGE INNER  -->
</div>
<script>
$(document).ready(function(){
	$("#tags").tagsinput('items');

});
function checkSubmit() {
	console.log(window.event.keyCode);
	return false;
	if(window.event.keyCode==13){
		return false;
	}
}
</script>
@stop